package io.github.lee.app.unsplash.global.di.database

import android.content.Context
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import io.github.lee.app.unsplash.repository.dao.SearchKeywordDao

@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {
    @Provides
    fun provideUnsplashDatabase(@ApplicationContext context: Context): UnsplashDatabase =
        Room.databaseBuilder(
            context,
            UnsplashDatabase::class.java,
            "${context.packageName}.db"
        )
            .build()

    @Provides
    fun provideSearchKeywordDao(database: UnsplashDatabase): SearchKeywordDao =
        database.searchKeywordDao()

}